package com.jingdong.dao.user.impl;

import com.jingdong.dao.user.UserDao;
import com.jingdong.model.User;
import com.jingdong.utils.MyBatisUtils;
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

@Repository
public class UserDaoImpl  implements UserDao{
    public User Login(String userName, String pwd) {
        try{
            Map<String,String>map=new HashMap<String, String>();
            map.put("userName",userName);
            map.put("pwd",pwd);
            SqlSession sqlSession = MyBatisUtils.getSqlSession();
            User user=sqlSession.selectOne("com.jingdong.userModel.login",map);
            return user;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void main(String[] args) {
        UserDaoImpl dao=new UserDaoImpl();

     User user=   dao .Login("test","test123");
        System.out.println(user.getUser_name());
    }
}
